﻿<%@ Page Title="Kakaroto's Kitchen" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Cozinha.aspx.cs" Inherits="Kakaroto.Pedidos.Preparo.Cozinha" %>

<asp:Content ID="Conteudo" ContentPlaceHolderID="MainContent" runat="server">

    <%--<asp:ScriptManager ID="ScriptManager1" runat="server" ></asp:ScriptManager>--%>
    <asp:UpdatePanel ID="up" runat="server">
        <ContentTemplate>
            <asp:Timer ID="Timer1" Interval="1000" runat="server" OnTick="Timer1_Tick"></asp:Timer>
            <asp:GridView ID="GridViewCozinha" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource" GridLines="Vertical" CellPadding="4" CssClass="table table-striped table-bordered" DataKeyNames="Id" OnRowDataBound="GridViewCozinha_DataBound">
                <Columns>
                    <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" HeaderStyle-Font-Size="Small" ItemStyle-Font-Size="Small" ReadOnly="True" ItemStyle-CssClass="hide" HeaderStyle-CssClass="hide"></asp:BoundField>
                    <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" HeaderStyle-Font-Size="Small" ItemStyle-Font-Size="Small" ReadOnly="True" ItemStyle-CssClass="hide" HeaderStyle-CssClass="hide"></asp:BoundField>
                    <asp:BoundField DataField="Quantidade" HeaderText="Qttd." SortExpression="Quantidade" HeaderStyle-Font-Size="Small" ItemStyle-Font-Size="Small" ReadOnly="True" HeaderStyle-Width="5%"></asp:BoundField>
                    <asp:BoundField DataField="Categoria" HeaderText="Categoria" SortExpression="Categoria" HeaderStyle-Font-Size="Small" ItemStyle-Font-Size="Small" ReadOnly="True" HeaderStyle-Width="15%"></asp:BoundField>
                    <asp:BoundField DataField="Prato" HeaderText="Prato" SortExpression="Prato" HeaderStyle-Font-Size="Small" ItemStyle-Font-Size="Small" ReadOnly="True" HeaderStyle-Width="15%"></asp:BoundField>
                    <asp:BoundField DataField="Obs" HeaderText="Obs" SortExpression="Obs" HeaderStyle-Font-Size="Small" ItemStyle-Font-Size="Small" ReadOnly="True" HeaderStyle-Width="15%"></asp:BoundField>
                    <asp:BoundField DataField="Hora" HeaderText="Hora" SortExpression="Hora" HeaderStyle-Font-Size="Small" ItemStyle-Font-Size="Small" ReadOnly="True"></asp:BoundField>
                    <asp:BoundField DataField="Mesa" HeaderText="Mesa" SortExpression="Mesa" HeaderStyle-Font-Size="Small" ItemStyle-Font-Size="Small" ReadOnly="True"></asp:BoundField>
                    <asp:BoundField DataField="Cliente" HeaderText="Cliente" SortExpression="Cliente" HeaderStyle-Font-Size="Small" ItemStyle-Font-Size="Small" ReadOnly="True"></asp:BoundField>
                    <asp:TemplateField HeaderText="Status" HeaderStyle-Font-Size="Small" SortExpression="Status" HeaderStyle-Width="221">
                        <EditItemTemplate>
                            <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Status") %>' />
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Button ID="Preparo" runat="server" Text="Preparo" Enabled="true" OnClick="Preparo_Click" CssClass="btn btn-primary" Width="100" />
                            <asp:Button ID="Pronto" runat="server" Text="Pronto" Enabled="true" OnClick="Pronto_Click" CssClass="btn btn-danger" Width="100" />
                        </ItemTemplate>
                    </asp:TemplateField>

                </Columns>
            </asp:GridView>

            <asp:SqlDataSource ID="SqlDataSource" runat="server" ConnectionString="Data Source=tcp:kakaroto-server.database.windows.net,1433;Initial Catalog=kakaroto-db;Integrated Security=False;User ID=kakarotoadmin@kakaroto-server;Password=0iEuSouOGoku#;MultipleActiveResultSets=True;Connect Timeout=30;Encrypt=True;Application Name=EntityFramework" 
                ProviderName="System.Data.SqlClient" 
                SelectCommand="SELECT ItemPedido.Id AS Id, ItemPedido.Qtdd AS Quantidade, Categoria.Nome As Categoria, Produto.Nome AS Prato, ItemPedido.Observacao AS Obs, ItemPedido.Hora, Pedido.Id_Mesa AS Mesa, Pedido.Cliente_Nome AS Cliente, ItemPedido.Pronto AS Status FROM Pedido INNER JOIN ItemPedido ON Pedido.Id = ItemPedido.Id_Ped INNER JOIN Produto ON ItemPedido.Id_Prod = Produto.Id INNER JOIN Categoria ON Produto.Id_Cat = Categoria.Id WHERE ((ItemPedido.Pronto is NULL) OR (ItemPedido.Pronto = 0)) AND (Produto.Id_Cat <> 2) ORDER BY Status ASC, ItemPedido.Hora ASC" 
                UpdateCommand="UPDATE ItemPedido SET Pronto = @Status WHERE (Id = @Id)"></asp:SqlDataSource>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
